package com.ate.ui.fragments;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.ate.javamvp.R;
import com.ate.lib_core.http.mvp.view.BaseFragment;
import com.bumptech.glide.Glide;

import org.json.JSONException;
import org.json.JSONObject;

public class UserFragment extends BaseFragment {
    private ImageView userImg;
    private TextView userId;

    @Override
    public int bandlayout() {
        return R.layout.fragment_user;
    }

    @Override
    public void initView() {
        userImg = (ImageView) findViewById(R.id.user_img);
        userId = (TextView) findViewById(R.id.user_id);

    }

    @Override
    public void initData() {
        Glide.with(this).load("https://img.alicdn.com/i1/2200658415558/O1CN019o0Ika2AkQSdGrfch_!!3325168241.jpg")
                .circleCrop().into(userImg);
        SharedPreferences sp = getActivity().getSharedPreferences("login", Context.MODE_PRIVATE);
        String str = sp.getString("jsonobject", null);
        if (str!=null){
            try {
                JSONObject jsonObject = new JSONObject(str);
                JSONObject data = jsonObject.getJSONObject("data");
                String username = data.getString("username");
                userId.setText(username);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

    }
}